/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Clients;

import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author Cliff
 */
public class ClientList {

    private ArrayList<Client> clientList;

    /**
     * 
     * @param client 
     */
    public void addClient(Client client) {
        clientList.add(client);
    }

    /**
     * 
     * @param id 
     */
    public void removeClient(int id) throws IOException {
        for (int i = 0; i < clientList.size(); i++) {
            if (clientList.get(i).getId() == id) {
                clientList.get(i).disconnect();
                clientList.remove(i);
            }
        }
    }

    /**
     * 
     */
    public void removeAllClients() throws IOException {
        for (int i = 0; i < clientList.size(); i++) {
            clientList.get(i).disconnect();
            clientList.remove(i);
        }
    }

    /**
     * 
     * @param id
     * @return 
     */
    public Client getMember(int id) {
        for (int i = 0; i < clientList.size(); i++) {
            if (clientList.get(i).getId() == id) {
                return clientList.get(i);
            }
        }
        return null;
    }
}
